package com.ddm.controller.wxadmin;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ddm.context.BaseContext;
import com.ddm.entity.vxEntity.BonusPoints;
import com.ddm.result.Result;
import com.ddm.service.vxService.BonusPointService;
import com.ddm.vo.vxVo.BonusPointsStatisticsVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/bonusponit")
@Slf4j
public class BonusPointController {

    @Autowired
    BonusPointService bonusPointService;

    @GetMapping("/{id}")
    @ApiOperation("获取用户积分")
    public Result getUserBonusPoint(@PathVariable Long id){
        log.info("获取用户积分");
        LambdaQueryWrapper<BonusPoints> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BonusPoints::getUserId, id);
        BonusPoints points = bonusPointService.getOne(wrapper);
        return Result.success(points);
    }

    @GetMapping("/statistics")
    @ApiOperation("获取所有用户总积分统计")
    public Result<BonusPointsStatisticsVO> getTotalPointsStatistics(){
        log.info("获取所有用户总积分统计");
        return Result.success(bonusPointService.getTotalPointsStatistics());
    }
}

